﻿ALTER TABLE public.countries ADD CONSTRAINT countries_twoletterisocode_key UNIQUE (twoletterisocode);
ALTER TABLE public.wiki_titles ADD CONSTRAINT wiki_titles_pkey PRIMARY KEY (titleid);
ALTER TABLE public.wiki_settings ADD CONSTRAINT wiki_settings_pkey PRIMARY KEY (wikisettingid);
ALTER TABLE public.wiki_contents ADD CONSTRAINT wiki_contents_pkey PRIMARY KEY (contentid);
ALTER TABLE public.weighted_content_widgets_roles ADD CONSTRAINT weightedcontentwidgetsroles_pkey PRIMARY KEY (weightedcontentwidgetid, roleid);
ALTER TABLE public.weighted_content_widgets ADD CONSTRAINT weightedcontentwidgets_pkey PRIMARY KEY (weightedcontentwidgetid);
ALTER TABLE public.weighted_content_modules_roles ADD CONSTRAINT weightedcontentmodulesroles_pkey PRIMARY KEY (weightedcontentmoduleid, roleid);
ALTER TABLE public.weighted_content_modules ADD CONSTRAINT weightedcontentmodules_pkey PRIMARY KEY (weightedcontentmoduleid);
ALTER TABLE public.weighted_content ADD CONSTRAINT weightedcontent_pkey PRIMARY KEY (weightedcontentid);
ALTER TABLE public.usersinroles ADD CONSTRAINT usersinroles_pkey PRIMARY KEY (userid, roleid);
ALTER TABLE public.users ADD CONSTRAINT users_pkey PRIMARY KEY (userid);
ALTER TABLE public.tracker_tickets ADD CONSTRAINT tracker_tickets_pkey PRIMARY KEY (ticketid);
ALTER TABLE public.tracker_ticket_notifications ADD CONSTRAINT tracker_ticketnotifications_pkey PRIMARY KEY (notificationid);
ALTER TABLE public.tracker_ticket_history ADD CONSTRAINT tracker_tickethistory_pkey PRIMARY KEY (historyid);
ALTER TABLE public.tracker_ticket_comments ADD CONSTRAINT tracker_ticketcomments_pkey PRIMARY KEY (commentid);
ALTER TABLE public.tracker_ticket_attachments ADD CONSTRAINT tracker_ticketattachments_pkey PRIMARY KEY (attachmentid);
ALTER TABLE public.tracker_projects ADD CONSTRAINT tracker_projects_pkey PRIMARY KEY (projectid);
ALTER TABLE public.tracker_project_statuses ADD CONSTRAINT tracker_projectstatuses_pkey PRIMARY KEY (statusid);
ALTER TABLE public.tracker_project_priorities ADD CONSTRAINT tracker_projectpriorities_pkey PRIMARY KEY (priorityid);
ALTER TABLE public.tracker_project_notifications ADD CONSTRAINT tracker_projectnotifications_pkey PRIMARY KEY (notificationid);
ALTER TABLE public.tracker_project_milestones ADD CONSTRAINT tracker_projectmilestones_pkey PRIMARY KEY (milestoneid);
ALTER TABLE public.tracker_project_members ADD CONSTRAINT tracker_projectmembers_pkey PRIMARY KEY (projectmemberid, projectid, userid);
ALTER TABLE public.tracker_project_customfields ADD CONSTRAINT tracker_projectcustomfields_pkey PRIMARY KEY (customfieldid);
ALTER TABLE public.tracker_project_custom_field_values ADD CONSTRAINT tracker_projectcustomfieldvalues_pkey PRIMARY KEY (bugid, customfieldid);
ALTER TABLE public.tracker_project_categories ADD CONSTRAINT tracker_projectcategories_pkey PRIMARY KEY (categoryid);
ALTER TABLE public.tracker_help_pages ADD CONSTRAINT tracker_helppages_pkey PRIMARY KEY (helppageid);
ALTER TABLE public.tracker_bugs ADD CONSTRAINT tracker_bugs_pkey PRIMARY KEY (bugid);
ALTER TABLE public.tracker_bug_notifications ADD CONSTRAINT tracker_bugnotifications_pkey PRIMARY KEY (notificationid);
ALTER TABLE public.tracker_bug_history ADD CONSTRAINT tracker_bughistory_pkey PRIMARY KEY (historyid);
ALTER TABLE public.tracker_bug_comments ADD CONSTRAINT tracker_bugcomments_pkey PRIMARY KEY (commentid);
ALTER TABLE public.tracker_bug_attachments ADD CONSTRAINT tracker_bugattachments_pkey PRIMARY KEY (attachmentid);
ALTER TABLE public.store_shipping_methods ADD CONSTRAINT store_shippingmethods_pkey PRIMARY KEY (shippingmethodid);
ALTER TABLE public.store_shipping_method_rates ADD CONSTRAINT store_shippingmethodrates_pkey PRIMARY KEY (shippingrateid);
ALTER TABLE public.store_products_pricing_options ADD CONSTRAINT store_products_pricingoptions_pkey PRIMARY KEY (pricingoptionid, productid);
ALTER TABLE public.store_products ADD CONSTRAINT store_products_pkey PRIMARY KEY (productid);
ALTER TABLE public.store_pricing_options ADD CONSTRAINT store_pricingoptions_pkey PRIMARY KEY (priceoptionid);
ALTER TABLE public.store_payments ADD CONSTRAINT store_payments_pkey PRIMARY KEY (paymentid);
ALTER TABLE public.store_orders ADD CONSTRAINT store_orders_pkey PRIMARY KEY (orderid);
ALTER TABLE public.store_order_details ADD CONSTRAINT store_orderdetails_pkey PRIMARY KEY (orderdetailid);
ALTER TABLE public.store_categories ADD CONSTRAINT store_categories_pkey PRIMARY KEY (categoryid);
ALTER TABLE public.store_carts ADD CONSTRAINT store_carts_pkey PRIMARY KEY (recordid);
ALTER TABLE public.state_provinces ADD CONSTRAINT stateprovinces_pkey PRIMARY KEY (stateprovinceid);
ALTER TABLE public.social_messagetypes ADD CONSTRAINT social_messagetypes_pkey PRIMARY KEY (messagetypeid);
ALTER TABLE public.social_messages ADD CONSTRAINT social_messages_pkey PRIMARY KEY (messageid);
ALTER TABLE public.social_likes ADD CONSTRAINT social_likes_pkey PRIMARY KEY (likeid);
ALTER TABLE public.social_images ADD CONSTRAINT social_images_pkey PRIMARY KEY (imageid);
ALTER TABLE public.social_data ADD CONSTRAINT social_data_pkey PRIMARY KEY (socialdataid);
ALTER TABLE public.roles ADD CONSTRAINT roles_pkey PRIMARY KEY (roleid);
ALTER TABLE public.optin_users_lists ADD CONSTRAINT optin_userslists_pkey PRIMARY KEY (userid, listid);
ALTER TABLE public.optin_subscribers_lists ADD CONSTRAINT optin_subscriberslists_pkey PRIMARY KEY (subscriberlistid);
ALTER TABLE public.optin_subscribers ADD CONSTRAINT optin_subscribers_pkey PRIMARY KEY (subscriberid);
ALTER TABLE public.optin_newsletters ADD CONSTRAINT optin_newsletters_pkey PRIMARY KEY (newsletterid);
ALTER TABLE public.optin_newsletter_lists ADD CONSTRAINT optin_newsletterlists_pkey PRIMARY KEY (newsletterid, listid);
ALTER TABLE public.optin_lists ADD CONSTRAINT optin_lists_pkey PRIMARY KEY (listid);
ALTER TABLE public.optin_link_tracking ADD CONSTRAINT optin_linktracking_pkey PRIMARY KEY (linktrackingid);
ALTER TABLE public.optin_attachments ADD CONSTRAINT optin_attachments_pkey PRIMARY KEY (attachmentid);
ALTER TABLE public.languages ADD CONSTRAINT languages_pkey PRIMARY KEY (languageid);
ALTER TABLE public.forum_votes ADD CONSTRAINT forum_votes_pkey PRIMARY KEY (postid, userid);
ALTER TABLE public.forum_posts ADD CONSTRAINT forum_posts_pkey PRIMARY KEY (postid);
ALTER TABLE public.forum_forums ADD CONSTRAINT forum_forums_pkey PRIMARY KEY (forumid);
ALTER TABLE public.countries ADD CONSTRAINT countries_pkey PRIMARY KEY (countryid);
ALTER TABLE public.cms_zones ADD CONSTRAINT zones_pkey PRIMARY KEY (zoneid);
ALTER TABLE public.cms_widgets ADD CONSTRAINT widgets_pkey PRIMARY KEY (widgetid);
ALTER TABLE public.cms_themes ADD CONSTRAINT themes_pkey PRIMARY KEY (themeid);
ALTER TABLE public.cms_search_log ADD CONSTRAINT searchlog_pkey PRIMARY KEY (searchtermid);
ALTER TABLE public.cms_redirects ADD CONSTRAINT redirects_pkey PRIMARY KEY (redirect301id);
ALTER TABLE public.cms_profiles ADD CONSTRAINT profiles_pkey PRIMARY KEY (profileid);
ALTER TABLE public.cms_portals ADD CONSTRAINT portals_pkey PRIMARY KEY (portalid);
ALTER TABLE public.cms_portal_resources ADD CONSTRAINT portalresources_pkey PRIMARY KEY (portalresourceid);
ALTER TABLE public.cms_portal_resource_types ADD CONSTRAINT portalresourcetypes_pkey PRIMARY KEY (portalresourcetypeid);
ALTER TABLE public.cms_modules ADD CONSTRAINT modules_pkey PRIMARY KEY (moduleid);
ALTER TABLE public.cms_log ADD CONSTRAINT log_pkey PRIMARY KEY (id);
ALTER TABLE public.cms_feedback_items ADD CONSTRAINT feedbackitems_pkey PRIMARY KEY (feedbackitemid);
ALTER TABLE public.cms_email_templates ADD CONSTRAINT emailtemplates_pkey PRIMARY KEY (emailtemplateid);
ALTER TABLE public.cms_content_pages ADD CONSTRAINT contentpages_pkey PRIMARY KEY (contentpageid);
ALTER TABLE public.cms_content_comments ADD CONSTRAINT contentcomments_pkey PRIMARY KEY (commentid);
ALTER TABLE public.cms_content_categories ADD CONSTRAINT contentcategories_pkey PRIMARY KEY (categoryid);
ALTER TABLE public.cms_areas ADD CONSTRAINT areas_pkey PRIMARY KEY (areaid);
ALTER TABLE public.wiki_titles ADD CONSTRAINT fk_wiki_titles_users FOREIGN KEY (userid) REFERENCES users(userid);
ALTER TABLE public.wiki_titles ADD CONSTRAINT fk_wiki_titles_portals FOREIGN KEY (portalid) REFERENCES cms_portals(portalid);
ALTER TABLE public.wiki_settings ADD CONSTRAINT fk_wiki_settings_portals FOREIGN KEY (portalid) REFERENCES cms_portals(portalid);
ALTER TABLE public.wiki_contents ADD CONSTRAINT fk_wiki_contents_wiki_titles FOREIGN KEY (titleid) REFERENCES wiki_titles(titleid);
ALTER TABLE public.wiki_contents ADD CONSTRAINT fk_wiki_contents_users FOREIGN KEY (userid) REFERENCES users(userid);
ALTER TABLE public.weighted_content_widgets_roles ADD CONSTRAINT fk_weightedcontentwidgetsroles_weightedcontentwidgets FOREIGN KEY (weightedcontentwidgetid) REFERENCES weighted_content_widgets(weightedcontentwidgetid);
ALTER TABLE public.weighted_content_widgets_roles ADD CONSTRAINT fk_weightedcontentwidgetsroles_roles FOREIGN KEY (roleid) REFERENCES roles(roleid);
ALTER TABLE public.weighted_content_widgets ADD CONSTRAINT fk_weightedcontentwidgets_widgets FOREIGN KEY (widgetid) REFERENCES cms_widgets(widgetid);
ALTER TABLE public.weighted_content_widgets ADD CONSTRAINT fk_weightedcontentwidgets_weightedcontent FOREIGN KEY (weightedcontentid) REFERENCES weighted_content(weightedcontentid);
ALTER TABLE public.weighted_content_modules_roles ADD CONSTRAINT fk_weightedcontentmodulesroles_weightedcontentmodules FOREIGN KEY (weightedcontentmoduleid) REFERENCES weighted_content_modules(weightedcontentmoduleid);
ALTER TABLE public.weighted_content_modules_roles ADD CONSTRAINT fk_weightedcontentmodulesroles_roles FOREIGN KEY (roleid) REFERENCES roles(roleid);
ALTER TABLE public.weighted_content_modules ADD CONSTRAINT fk_weightedcontentmodules_weightedcontent FOREIGN KEY (weightedcontentid) REFERENCES weighted_content(weightedcontentid);
ALTER TABLE public.weighted_content_modules ADD CONSTRAINT fk_weightedcontentmodules_modules FOREIGN KEY (moduleid) REFERENCES cms_modules(moduleid);
ALTER TABLE public.weighted_content ADD CONSTRAINT fk_weightedcontent_users FOREIGN KEY (portaladmin) REFERENCES users(userid);
ALTER TABLE public.weighted_content ADD CONSTRAINT fk_weightedcontent_portals FOREIGN KEY (portalid) REFERENCES cms_portals(portalid);
ALTER TABLE public.usersinroles ADD CONSTRAINT fk__usersinro__useri__2d27b809 FOREIGN KEY (userid) REFERENCES users(userid);
ALTER TABLE public.usersinroles ADD CONSTRAINT fk__usersinro__rolei__2c3393d0 FOREIGN KEY (roleid) REFERENCES roles(roleid);
ALTER TABLE public.users ADD CONSTRAINT fk_users_portals FOREIGN KEY (portalid) REFERENCES cms_portals(portalid);
ALTER TABLE public.tracker_tickets ADD CONSTRAINT fk_tracker_ticket_users1 FOREIGN KEY (creatoruserid) REFERENCES users(userid);
ALTER TABLE public.tracker_tickets ADD CONSTRAINT fk_tracker_ticket_users FOREIGN KEY (assigneduserid) REFERENCES users(userid);
ALTER TABLE public.tracker_tickets ADD CONSTRAINT fk_tracker_ticket_tracker_projectstatuses FOREIGN KEY (statusid) REFERENCES tracker_project_statuses(statusid);
ALTER TABLE public.tracker_tickets ADD CONSTRAINT fk_tracker_ticket_tracker_projects FOREIGN KEY (projectid) REFERENCES tracker_projects(projectid);
ALTER TABLE public.tracker_tickets ADD CONSTRAINT fk_tracker_ticket_tracker_projectpriorities FOREIGN KEY (priorityid) REFERENCES tracker_project_priorities(priorityid);
ALTER TABLE public.tracker_tickets ADD CONSTRAINT fk_tracker_ticket_tracker_bugs FOREIGN KEY (developerticketid) REFERENCES tracker_bugs(bugid);
ALTER TABLE public.tracker_ticket_notifications ADD CONSTRAINT fk_ticketnotifications_tickets FOREIGN KEY (ticketid) REFERENCES tracker_tickets(ticketid);
ALTER TABLE public.tracker_ticket_history ADD CONSTRAINT fk_tickethistory_tickets FOREIGN KEY (ticketid) REFERENCES tracker_tickets(ticketid);
ALTER TABLE public.tracker_ticket_comments ADD CONSTRAINT fk_ticketcomments_tickets FOREIGN KEY (ticketid) REFERENCES tracker_tickets(ticketid);
ALTER TABLE public.tracker_ticket_attachments ADD CONSTRAINT fk_ticketattachments_tickets FOREIGN KEY (ticketid) REFERENCES tracker_tickets(ticketid);
ALTER TABLE public.tracker_projects ADD CONSTRAINT fk_tracker_projects_portals FOREIGN KEY (portalid) REFERENCES cms_portals(portalid);
ALTER TABLE public.tracker_project_statuses ADD CONSTRAINT fk_projectstatus_projects FOREIGN KEY (projectid) REFERENCES tracker_projects(projectid);
ALTER TABLE public.tracker_project_priorities ADD CONSTRAINT fk_projectpriorities_projects FOREIGN KEY (projectid) REFERENCES tracker_projects(projectid);
ALTER TABLE public.tracker_project_notifications ADD CONSTRAINT fk_tracker_bugattachmentsnotifications_tracker_bugattachments FOREIGN KEY (projectid) REFERENCES tracker_projects(projectid);
ALTER TABLE public.tracker_project_milestones ADD CONSTRAINT fk_projectmilestones_projects FOREIGN KEY (projectid) REFERENCES tracker_projects(projectid);
ALTER TABLE public.tracker_project_members ADD CONSTRAINT fk_tracker_projectmembers_users FOREIGN KEY (userid) REFERENCES users(userid);
ALTER TABLE public.tracker_project_members ADD CONSTRAINT fk_projectmembers_projects FOREIGN KEY (projectid) REFERENCES tracker_projects(projectid);
ALTER TABLE public.tracker_project_customfields ADD CONSTRAINT fk_projectcustomfields_projects FOREIGN KEY (projectid) REFERENCES tracker_projects(projectid);
ALTER TABLE public.tracker_project_custom_field_values ADD CONSTRAINT fk_tracker_projectcustomfieldvalues_tracker_bugs FOREIGN KEY (bugid) REFERENCES tracker_bugs(bugid);
ALTER TABLE public.tracker_project_custom_field_values ADD CONSTRAINT fk_projectcustomfieldvalues_projectcustomfields FOREIGN KEY (customfieldid) REFERENCES tracker_project_customfields(customfieldid);
ALTER TABLE public.tracker_project_categories ADD CONSTRAINT fk_projectcategories_projects FOREIGN KEY (projectid) REFERENCES tracker_projects(projectid);
ALTER TABLE public.tracker_help_pages ADD CONSTRAINT fk_tracker_helppages_portals FOREIGN KEY (portalid) REFERENCES cms_portals(portalid);
ALTER TABLE public.tracker_help_pages ADD CONSTRAINT fk_tracker_helppages_contentpages FOREIGN KEY (contentpageid) REFERENCES cms_content_pages(contentpageid);
ALTER TABLE public.tracker_bugs ADD CONSTRAINT fk_tracker_bugs_users FOREIGN KEY (assigneduserid) REFERENCES users(userid);
ALTER TABLE public.tracker_bugs ADD CONSTRAINT fk_bugs_projectstatuses FOREIGN KEY (statusid) REFERENCES tracker_project_statuses(statusid);
ALTER TABLE public.tracker_bugs ADD CONSTRAINT fk_bugs_projects FOREIGN KEY (projectid) REFERENCES tracker_projects(projectid);
ALTER TABLE public.tracker_bugs ADD CONSTRAINT fk_bugs_projectpriorities FOREIGN KEY (priorityid) REFERENCES tracker_project_priorities(priorityid);
ALTER TABLE public.tracker_bugs ADD CONSTRAINT fk_bugs_projectmilestones FOREIGN KEY (milestoneid) REFERENCES tracker_project_milestones(milestoneid);
ALTER TABLE public.tracker_bugs ADD CONSTRAINT fk_bugs_projectcategories FOREIGN KEY (categoryid) REFERENCES tracker_project_categories(categoryid);
ALTER TABLE public.tracker_bugs ADD CONSTRAINT fk_bugs_bugs FOREIGN KEY (parentbugid) REFERENCES tracker_bugs(bugid);
ALTER TABLE public.tracker_bug_notifications ADD CONSTRAINT fk_bugnotifications_bugs FOREIGN KEY (bugid) REFERENCES tracker_bugs(bugid);
ALTER TABLE public.tracker_bug_history ADD CONSTRAINT fk_bughistory_bugs FOREIGN KEY (bugid) REFERENCES tracker_bugs(bugid);
ALTER TABLE public.tracker_bug_comments ADD CONSTRAINT fk_bugcomments_bugs FOREIGN KEY (bugid) REFERENCES tracker_bugs(bugid);
ALTER TABLE public.tracker_bug_attachments ADD CONSTRAINT fk_bugattachments_bugs FOREIGN KEY (bugid) REFERENCES tracker_bugs(bugid);
ALTER TABLE public.store_shipping_methods ADD CONSTRAINT fk_store_shippingmethods_portals FOREIGN KEY (portalid) REFERENCES cms_portals(portalid);
ALTER TABLE public.store_shipping_method_rates ADD CONSTRAINT fk_store_shippingmethodrate_store_shippingmethods FOREIGN KEY (shippingmethodid) REFERENCES store_shipping_methods(shippingmethodid);
ALTER TABLE public.store_products_pricing_options ADD CONSTRAINT fk_store_products_pricingoptions_store_products FOREIGN KEY (productid) REFERENCES store_products(productid);
ALTER TABLE public.store_products_pricing_options ADD CONSTRAINT fk_store_products_pricingoptions_store_pricingoptions FOREIGN KEY (pricingoptionid) REFERENCES store_pricing_options(priceoptionid);
ALTER TABLE public.store_products ADD CONSTRAINT fk_store_products_store_categories FOREIGN KEY (categoryid) REFERENCES store_categories(categoryid);
ALTER TABLE public.store_pricing_options ADD CONSTRAINT fk_store_pricingoptions_portals FOREIGN KEY (portalid) REFERENCES cms_portals(portalid);
ALTER TABLE public.store_orders ADD CONSTRAINT fk_store_orders_users FOREIGN KEY (userid) REFERENCES users(userid);
ALTER TABLE public.store_orders ADD CONSTRAINT fk_store_orders_store_shippingmethodrates FOREIGN KEY (shippingrateid) REFERENCES store_shipping_method_rates(shippingrateid);
ALTER TABLE public.store_orders ADD CONSTRAINT fk_store_orders_portals FOREIGN KEY (portalid) REFERENCES cms_portals(portalid);
ALTER TABLE public.store_orders ADD CONSTRAINT fk_store_orders_payments FOREIGN KEY (paymentid) REFERENCES store_payments(paymentid);
ALTER TABLE public.store_order_details ADD CONSTRAINT orderdetail_product FOREIGN KEY (productid) REFERENCES store_products(productid);
ALTER TABLE public.store_order_details ADD CONSTRAINT order_orderdetails FOREIGN KEY (orderid) REFERENCES store_orders(orderid);
ALTER TABLE public.store_order_details ADD CONSTRAINT fk_store_orderdetails_store_pricingoptions FOREIGN KEY (priceoptionid) REFERENCES store_pricing_options(priceoptionid);
ALTER TABLE public.store_categories ADD CONSTRAINT fk_store_categories_portals FOREIGN KEY (portalid) REFERENCES cms_portals(portalid);
ALTER TABLE public.store_carts ADD CONSTRAINT fk_store_carts_store_pricingoptions FOREIGN KEY (priceoptionid) REFERENCES store_pricing_options(priceoptionid);
ALTER TABLE public.store_carts ADD CONSTRAINT fk_store_carts_portals FOREIGN KEY (portalid) REFERENCES cms_portals(portalid);
ALTER TABLE public.store_carts ADD CONSTRAINT cart_product FOREIGN KEY (productid) REFERENCES store_products(productid);
ALTER TABLE public.social_messages ADD CONSTRAINT fk_social_messages_users1 FOREIGN KEY (touserid) REFERENCES users(userid);
ALTER TABLE public.social_messages ADD CONSTRAINT fk_social_messages_users FOREIGN KEY (fromuserid) REFERENCES users(userid);
ALTER TABLE public.social_messages ADD CONSTRAINT fk_social_messages_social_messagetypes FOREIGN KEY (messagetypeid) REFERENCES social_messagetypes(messagetypeid);
ALTER TABLE public.social_messages ADD CONSTRAINT fk_social_messages_social_messages FOREIGN KEY (parentmessageid) REFERENCES social_messages(messageid);
ALTER TABLE public.social_likes ADD CONSTRAINT fk_social_likes_users FOREIGN KEY (userid) REFERENCES users(userid);
ALTER TABLE public.social_likes ADD CONSTRAINT fk_social_likes_social_messages FOREIGN KEY (messageid) REFERENCES social_messages(messageid);
ALTER TABLE public.social_images ADD CONSTRAINT fk_social_images_users FOREIGN KEY (userid) REFERENCES users(userid);
ALTER TABLE public.social_data ADD CONSTRAINT fk_social_data_users FOREIGN KEY (userid) REFERENCES users(userid);
ALTER TABLE public.optin_users_lists ADD CONSTRAINT fk_userslists_lists FOREIGN KEY (listid) REFERENCES optin_lists(listid);
ALTER TABLE public.optin_users_lists ADD CONSTRAINT fk_optin_userslists_users FOREIGN KEY (userid) REFERENCES users(userid);
ALTER TABLE public.optin_subscribers_lists ADD CONSTRAINT fk_subscriberslists_subscribers FOREIGN KEY (subscriberid) REFERENCES optin_subscribers(subscriberid);
ALTER TABLE public.optin_subscribers_lists ADD CONSTRAINT fk_subscriberslists_lists FOREIGN KEY (listid) REFERENCES optin_lists(listid);
ALTER TABLE public.optin_subscribers ADD CONSTRAINT fk_optin_subscribers_portals FOREIGN KEY (portalid) REFERENCES cms_portals(portalid);
ALTER TABLE public.optin_newsletters ADD CONSTRAINT fk_optin_newsletters_users FOREIGN KEY (adminid) REFERENCES users(userid);
ALTER TABLE public.optin_newsletters ADD CONSTRAINT fk_optin_newsletters_portals FOREIGN KEY (portalid) REFERENCES cms_portals(portalid);
ALTER TABLE public.optin_newsletter_lists ADD CONSTRAINT fk_newsletterlists_newsletters FOREIGN KEY (newsletterid) REFERENCES optin_newsletters(newsletterid);
ALTER TABLE public.optin_newsletter_lists ADD CONSTRAINT fk_newsletterlists_lists FOREIGN KEY (listid) REFERENCES optin_lists(listid);
ALTER TABLE public.optin_lists ADD CONSTRAINT fk_optin_lists_users FOREIGN KEY (adminid) REFERENCES users(userid);
ALTER TABLE public.optin_lists ADD CONSTRAINT fk_optin_lists_portals FOREIGN KEY (portalid) REFERENCES cms_portals(portalid);
ALTER TABLE public.optin_link_tracking ADD CONSTRAINT fk_optin_linktracking_users FOREIGN KEY (adminid) REFERENCES users(userid);
ALTER TABLE public.optin_link_tracking ADD CONSTRAINT fk_linktracking_newsletters FOREIGN KEY (newsletterid) REFERENCES optin_newsletters(newsletterid);
ALTER TABLE public.optin_attachments ADD CONSTRAINT fk_optin_attachments_users FOREIGN KEY (adminid) REFERENCES users(userid);
ALTER TABLE public.optin_attachments ADD CONSTRAINT fk_attachments_newsletters FOREIGN KEY (newsletterid) REFERENCES optin_newsletters(newsletterid);
ALTER TABLE public.forum_votes ADD CONSTRAINT fk_votes_users FOREIGN KEY (userid) REFERENCES users(userid);
ALTER TABLE public.forum_votes ADD CONSTRAINT fk_votes_posts FOREIGN KEY (postid) REFERENCES forum_posts(postid);
ALTER TABLE public.forum_posts ADD CONSTRAINT fk_posts_users1 FOREIGN KEY (lastpostbyid) REFERENCES users(userid);
ALTER TABLE public.forum_posts ADD CONSTRAINT fk_posts_users FOREIGN KEY (userid) REFERENCES users(userid);
ALTER TABLE public.forum_posts ADD CONSTRAINT fk_posts_posts FOREIGN KEY (parentpostid) REFERENCES forum_posts(postid);
ALTER TABLE public.forum_posts ADD CONSTRAINT fk_posts_forums FOREIGN KEY (forumid) REFERENCES forum_forums(forumid);
ALTER TABLE public.forum_posts ADD CONSTRAINT fk_contentcomments_contentcomments FOREIGN KEY (parentpostid) REFERENCES forum_posts(postid);
ALTER TABLE public.forum_forums ADD CONSTRAINT fk_forums_users FOREIGN KEY (userid) REFERENCES users(userid);
ALTER TABLE public.forum_forums ADD CONSTRAINT fk_forums_portals FOREIGN KEY (portalid) REFERENCES cms_portals(portalid);
ALTER TABLE public.cms_zones ADD CONSTRAINT fk_zones_themes FOREIGN KEY (themeid) REFERENCES cms_themes(themeid);
ALTER TABLE public.cms_widgets ADD CONSTRAINT fk_widgets_users FOREIGN KEY (portaladmin) REFERENCES users(userid);
ALTER TABLE public.cms_widgets ADD CONSTRAINT fk_widgets_portals FOREIGN KEY (portalid) REFERENCES cms_portals(portalid);
ALTER TABLE public.cms_widgets ADD CONSTRAINT fk_widgets_contentpages FOREIGN KEY (contentpageid) REFERENCES cms_content_pages(contentpageid);
ALTER TABLE public.cms_widgets ADD CONSTRAINT fk_widgets_contentcategories FOREIGN KEY (contentcategoryid) REFERENCES cms_content_categories(categoryid);
ALTER TABLE public.cms_themes ADD CONSTRAINT fk_themes_portals FOREIGN KEY (portalid) REFERENCES cms_portals(portalid);
ALTER TABLE public.cms_redirects ADD CONSTRAINT fk_redirect301_portals FOREIGN KEY (portalid) REFERENCES cms_portals(portalid);
ALTER TABLE public.cms_profiles ADD CONSTRAINT fk_profiles_users FOREIGN KEY (userid) REFERENCES users(userid);
ALTER TABLE public.cms_profiles ADD CONSTRAINT fk_profiles_tracker_projects FOREIGN KEY (defaultprojectid) REFERENCES tracker_projects(projectid);
ALTER TABLE public.cms_profiles ADD CONSTRAINT fk_profiles_stateprovinces FOREIGN KEY (stateprovinceid) REFERENCES state_provinces(stateprovinceid);
ALTER TABLE public.cms_profiles ADD CONSTRAINT fk_profiles_languages FOREIGN KEY (languageid) REFERENCES languages(languageid);
ALTER TABLE public.cms_portals ADD CONSTRAINT fk_portals_users FOREIGN KEY (editedbyuserid) REFERENCES users(userid);
ALTER TABLE public.cms_portals ADD CONSTRAINT fk_portals_themes FOREIGN KEY (defaultthemeid) REFERENCES cms_themes(themeid);
ALTER TABLE public.cms_portals ADD CONSTRAINT fk_portals_languages FOREIGN KEY (defaultlanguageid) REFERENCES languages(languageid);
ALTER TABLE public.cms_portal_resources ADD CONSTRAINT fk_portalresources_users FOREIGN KEY (editedbyuserid) REFERENCES users(userid);
ALTER TABLE public.cms_portal_resources ADD CONSTRAINT fk_portalresources_portals FOREIGN KEY (portalid) REFERENCES cms_portals(portalid);
ALTER TABLE public.cms_portal_resources ADD CONSTRAINT fk_portalresources_portalresourcetypes FOREIGN KEY (portalresourcetypeid) REFERENCES cms_portal_resource_types(portalresourcetypeid);
ALTER TABLE public.cms_modules ADD CONSTRAINT fk_modules_portals FOREIGN KEY (portalid) REFERENCES cms_portals(portalid);
ALTER TABLE public.cms_modules ADD CONSTRAINT fk_modules_contentpages FOREIGN KEY (contentpageid) REFERENCES cms_content_pages(contentpageid);
ALTER TABLE public.cms_modules ADD CONSTRAINT fk_modules_contentcategories FOREIGN KEY (contentcategoryid) REFERENCES cms_content_categories(categoryid);
ALTER TABLE public.cms_feedback_items ADD CONSTRAINT fk_feedbackitems_portals FOREIGN KEY (portalid) REFERENCES cms_portals(portalid);
ALTER TABLE public.cms_email_templates ADD CONSTRAINT fk_emailtemplates_users FOREIGN KEY (userid) REFERENCES users(userid);
ALTER TABLE public.cms_email_templates ADD CONSTRAINT fk_emailtemplates_portals FOREIGN KEY (portalid) REFERENCES cms_portals(portalid);
ALTER TABLE public.cms_content_pages ADD CONSTRAINT fk_contentpages_users FOREIGN KEY (addedbyid) REFERENCES users(userid);
ALTER TABLE public.cms_content_pages ADD CONSTRAINT fk_contentpages_themes FOREIGN KEY (themeid) REFERENCES cms_themes(themeid);
ALTER TABLE public.cms_content_pages ADD CONSTRAINT fk_contentpages_portals FOREIGN KEY (portalid) REFERENCES cms_portals(portalid);
ALTER TABLE public.cms_content_pages ADD CONSTRAINT fk_contentpages_languages FOREIGN KEY (languageid) REFERENCES languages(languageid);
ALTER TABLE public.cms_content_pages ADD CONSTRAINT fk_contentpages_contributors FOREIGN KEY (contributorid) REFERENCES users(userid);
ALTER TABLE public.cms_content_pages ADD CONSTRAINT fk_contentpages_contentpages FOREIGN KEY (altlanguageforpageid) REFERENCES cms_content_pages(contentpageid);
ALTER TABLE public.cms_content_pages ADD CONSTRAINT fk_contentpages_contentcategories FOREIGN KEY (categoryid) REFERENCES cms_content_categories(categoryid);
ALTER TABLE public.cms_content_comments ADD CONSTRAINT fk_contentcomments_users FOREIGN KEY (addedbyid) REFERENCES users(userid);
ALTER TABLE public.cms_content_comments ADD CONSTRAINT fk_contentcomments_contentpages FOREIGN KEY (contentpageid) REFERENCES cms_content_pages(contentpageid);
ALTER TABLE public.cms_content_comments ADD CONSTRAINT fk_contentcomments_contentcomments FOREIGN KEY (parentcommentid) REFERENCES cms_content_comments(commentid);
ALTER TABLE public.cms_content_categories ADD CONSTRAINT fk_contentcategories_users FOREIGN KEY (addedbyid) REFERENCES users(userid);
ALTER TABLE public.cms_content_categories ADD CONSTRAINT fk_contentcategories_portals FOREIGN KEY (portalid) REFERENCES cms_portals(portalid);
ALTER TABLE public.cms_content_categories ADD CONSTRAINT fk_contentcategories_contentcategories FOREIGN KEY (parentcategoryid) REFERENCES cms_content_categories(categoryid);
ALTER TABLE public.cms_areas ADD CONSTRAINT fk_areas_users1 FOREIGN KEY (lasteditedby) REFERENCES users(userid);
ALTER TABLE public.cms_areas ADD CONSTRAINT fk_areas_users FOREIGN KEY (createdby) REFERENCES users(userid);
ALTER TABLE public.cms_areas ADD CONSTRAINT fk_areas_portals FOREIGN KEY (portalid) REFERENCES cms_portals(portalid);
